<?php if(isset($categories)): ?>
<div class="category-list">
  <ul class="thumbnails">
    <?php foreach($categories as $category): ?>
    <?php $fields = field_get_items('lonex_category', $category, 'field_category_image'); ?>
    <?php if(isset($fields[0])): ?>
      <?php $file = file_create_url($fields[0]['uri']); ?>
      <?php $image = l('<img title="'. $fields[0]['title'] .'" src = "' . $file . '">', 'catalog/' . $category->cid, array('html' => true, 'attributes' => array('class' => array('thumbnail')))); ?>

      <li class="span4">
        <div class="thumbnail">
          <?php print $image; ?>
          <div class="caption">
            <span class="category-list-item"><?php print $category->title; ?></span>
            <?php print modifier_mb_truncate($category->params, 260); ?><br>
            <?php print l(t('Перейти'), 'catalog/' . $category->cid, array('attributes' => array('class' => array('btn', 'btn-primary')))); ?>
          </div>
        </div>
      </li>

      <?php endif; ?>
    <?php endforeach; ?>
  </ul>
</div>
<?php endif; ?>
